package com.baidu.user.service.impl;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baidu.user.dao.UserMapper;
import com.baidu.user.entity.User;
import com.baidu.user.entity.UserBasicInfo;
import com.baidu.user.entity.UserCustom;
import com.baidu.user.service.UserService;

@Service
public class UserServiceImpl implements UserService{

	@Autowired
	private UserMapper userMapper ;

	public User login(String loginname, String password) {
		// TODO Auto-generated method stub
		User user= new User();
		user.setLoginname(loginname);
		user.setPassword(password);
		return userMapper.login(user);
	}

	public void register(User model) {
		// TODO Auto-generated method stub
		User user = new User();
		user.setAge(model.getAge());
		user.setLoginname(model.getLoginname());
		user.setMail(model.getMail());
		user.setPassword(model.getPassword());
		user.setPhone(model.getPhone());
		user.setRealname(model.getRealname());
		user.setSex(model.getSex());
		user.setClassid(model.getClassid());
		user.setTypeid(model.getTypeid());
		user.setStatus("未授权");
		userMapper.insert(user);
	}

	public void update(User model) {
		// TODO Auto-generated method stub
		User user = new User();
		user.setId(model.getId());
		user.setAge(model.getAge());
		user.setLoginname(model.getLoginname());
		user.setMail(model.getMail());
		user.setPassword(model.getPassword());
		user.setPhone(model.getPhone());
		user.setRealname(model.getRealname());
		user.setSex(model.getSex());
		user.setClassid(model.getClassid());
		user.setTypeid(model.getTypeid());
		user.setStatus("未授权");
		userMapper.updateByPrimaryKey(user);
	}

	public UserCustom findById(BigDecimal id) {
		// TODO Auto-generated method stub
		return userMapper.findById(id);
	}

	public List<Object> getFirstTeachers() {
		// TODO Auto-generated method stub
		List<Object> list = userMapper.getFirstTeachers();
		return userMapper.getFirstTeachers();
	}

	public List<Object> getSecondTree() {
		// TODO Auto-generated method stub
		return userMapper.getSecondTree();
	}

	public UserBasicInfo findBasicUserById(BigDecimal id) {
		// TODO Auto-generated method stub
		return userMapper.findBasicUserById(id);
	}
	
	
}
